/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//		File Name		:		CatherineAIState.h
//
//		Author			:		Kevin Jordan
//
//		Purpose			:		Encapsulate all functionality in the Catherines AI class
//
//		Dates			:		Written( March 8, 2011 ) by Kevin Jordan		LastUpdate( March 8, 2011  ) by Kevin Jordan	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "CatherineAIState.h"
#include "CHubState.h"
#include <ctime>
#include "SGD Wrappers/CSGD_Direct3D.h"


CatherineAIState::CatherineAIState()
{
	pTarget = NULL;
	pMe = NULL;
	CurState = 1;
	fBucket = 0.0f;
	Deviation = 0;
}



CatherineAIState::~CatherineAIState()
{




}

CatherineAIState* CatherineAIState::GetInstance()
{

	static CatherineAIState instance;
	return &instance;



}

void CatherineAIState::Update(float fElapsedTime)
{


	//Did you include <ctime>
	srand( unsigned int(time(0)));
	Deviation = (rand() % 5 + 1);

	if( !pTarget )
	{
		SetTarget();
	}

	float JetPackingGravity = 600.0f;

	switch( CurState )
	{
	case JETPACKING:
		{
			if( pTarget->GetHP() < 30 || m_uniJetPackHealth == 0 )
			{
				ChangeAIState(MELEE);
			}

			pMe->SetVelY( ( -250 - Deviation ) * fElapsedTime * JetPackingGravity );




		}
		break;
	case DOWNED:
		{
			fBucket += fElapsedTime;
			if( fBucket >= 5.0f )
			{
				ChangeAIState( JETPACKING );
			}

		}
		break;
	case MELEE:
		{

		}
		break;
	}


}


void CatherineAIState::SetTarget()
{
	pTarget = CHubState::GetInstance()->GetPlayer();

}

void CatherineAIState::ChangeAIState( int newState )
{
	CurState = newState;
}

void CatherineAIState::ReleasePointers()
{
	pMe = NULL;

}

void CatherineAIState::Render()
{
	CSGD_Direct3D* pD3D = CSGD_Direct3D::GetInstance();

	//RECT Collision;
	//SetRect( &Collision, int(GetPosX()), int(GetPosY()), int(GetPosX() + GetHeight()), int(GetPosY() + GetHeight()) );
	//pD3D->DrawRect( Collision, 0,255,0);
}


bool CatherineAIState::Input()
{



return true;

}